package info.ask4research.service.core.impl;

import info.ask4research.dao.core.AbstractDao;
import info.ask4research.service.core.AbstractService;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public abstract class AbstractServiceImpl<T> implements AbstractService<T> {

	/**
	 * @return AbstractDao<T, PK>
	 */
	public abstract AbstractDao<T> getDao();
	
	public abstract void setDao( AbstractDao<T> dao);


	@Override
	public T get(int id) {
		return getDao().get(id);
	}


	@Override
	public List<T> getAll() {
		return getDao().getAll();
	}


	@Override
	public boolean exists(int id) {
		return getDao().exists(id);
	}


	@Override
	public T save(T object) {
		return getDao().save(object);
	}


	@Override
	public void saveAll(List<T> elements) {
		getDao().saveAll(elements);
	}


	@Override
	public void removeAll() {
		getDao().removeAll();
	}


	@Override
	public void removeAll(List<T> elements) {
		getDao().removeAll(elements);
	}


	@Override
	public void remove(int id) {
		getDao().remove(id);
	}


	@Override
	public void remove(T entity) {
		getDao().remove(entity);
	}


	@Override
	public boolean contains(T object) {
		return getDao().contains(object);
	}
	
	@Override
	public void saveOrUpdate(T object){
		getDao().saveOrUpdate(object);
	}

}
